package MainTest;

public class Sort {

    public static void main(String[] args) {
        int[] arr = {2,1342,456,1,23,654,213,54,38,65};

        bubbleSort(arr);
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + ",");

        }

        int len = arr.length;
        for (int i = 0; i < len; i++) {
            int min = arr[i];
            for (int j = 0; j < len; j++) {
                int temp;
                int next = arr[j];
                if (next > min) {
                    temp = min;
                    min = next;
                    next = temp;
                    arr[i] = min;
                    arr[j] = next;
                }
            }
        }

        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + ",");

        }

    }

    public static void bubbleSort(int[] numbers) {
        int temp; // 记录临时中间值
        int size = numbers.length; // 数组大小
        for (int i = 0; i < size - 1; i++) {
            for (int j = i + 1; j < size; j++) {
                if (numbers[i] > numbers[j]) { // 交换两数的位置
                    temp = numbers[i];
                    numbers[i] = numbers[j];
                    numbers[j] = temp;
                }
            }
        }
    }


}
